/*
 * @Description: 
 * @Author: liuzl
 * @Date: 2024-11-08 14:51:35
 * @LastEditors: liuzl
 * @LastEditTime: 2024-11-08 14:51:35
 */
var loginObj = {
    username:"admin",
    password:"12345"
}

console.log('🚀TTT ~ loginObj.username:', loginObj.username)
console.log('🚀TTT ~ loginObj.password:', loginObj.password)

//json对象转json字符串
var loginTxt = JSON.stringify(loginObj);
console.log('🚀TTT ~ loginObj:', loginObj)
console.log('🚀TTT ~ loginTxt:', loginTxt)
//json字符串是序列化后的对象 是字符串 没有属性和值的概念
console.log('🚀TTT ~ loginText.username:', loginTxt.username)
//需要对json字符串进行反序列化才能拿到对应的属性和值
var user = JSON.parse(loginTxt)

console.log('🚀TTT ~ user:', user)
console.log('🚀TTT ~ user.username:', user.username)

//前后台分离开发
// class User{
//     String username;
//     String password;
// }
User u1 = new User("admin","12345");
//u1要进行序列化
//{"usernaem":"admin","password":"12345"}
//通过网络传输 前端拿到序列化后的字符串
//反序列化
//var user = JSON.parse(xxx)